﻿#include "pch.h"
#include "AbstractRenderer.h"

#include "RenderCommand.h"
#include "function/RenderSystem/OpenGL/OpenGLShader.h"

namespace Engine
{
	AbstractRenderer::RendererData* AbstractRenderer::rendererData = new RendererData;

	void AbstractRenderer::Init()
	{
		RenderCommand::Init();
	}

	void AbstractRenderer::BeforeRender(const Color4& clearColor, const Camera& camera)
	{
		RenderCommand::SetClearColor(clearColor);
		RenderCommand::Clear();

		rendererData->viewProjectionMatrix = camera.GetViewProjectionMatrix();
	}

	void AbstractRenderer::Submit(const Ref<VertexArray>& vertexArray, const Ref<AbstractShader>& shader)
	{
		vertexArray->Bind();
		shader->Bind();
		shader->SetUniformMat4("u_ViewProjection", rendererData->viewProjectionMatrix);
		RenderCommand::DrawCall(vertexArray);
	}

	void AbstractRenderer::AfterRender()
	{
	}
}
